package com.bbex.task.execute;

import com.bbex.service.impl.UserCoinVolumeBillTaskServiceImpl;
import com.bbex.task.service.CoinAddressTaskService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Component
public class ScheduledTasks {

    private static Logger logger = LoggerFactory.getLogger(ScheduledTasks.class);
    @Autowired
    private CoinAddressTaskService coinAddressService;
    @Autowired
    private UserCoinVolumeBillTaskServiceImpl userCoinVolumeBillTaskService;

    @Value("${generateAddress}")
    private String generateAddress;


    /**
     * 生产eth 地址
     */
    /*@Scheduled(fixedRate = 1000 * 60 * 10)
    public void generateEthAddress() {
        logger.info("generateEthAddress  start ....");
        try {
            if (!generateAddress.equals("1")) return;
            coinAddressService.executeAddress("ETH");
        } catch (Exception e) {
            e.printStackTrace();
        }
        logger.info("generateEthAddress   end   ....");
    }*/

    /**
     * 生产hmc 地址
     */
    /*@Scheduled(fixedRate = 1000 * 60 * 15)
    public void generateHmcAddress() {
        logger.info("generateHmcAddress  start ....");
        try {
            if (!generateAddress.equals("1")) return;
            coinAddressService.executeHmcAddress("HMC");
        } catch (Exception e) {
            e.printStackTrace();
        }
        logger.info("generateHmcAddress   end   ....");
    }*/

    @Scheduled(fixedRate = 1800 * 1000)
    public void scheduledUserCoinVolumebillHistory() {
        logger.info("请除userCoinVolumeBill的历史记录开始....");
        long execute = userCoinVolumeBillTaskService.execute();
        logger.info("请除userCoinVolumeBill的历史记录结束,处理{}条....", execute);
    }
}
